package com.rd.student.jiaji.class4.suyan.zrrd.Exercise08_07;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Scanner;

public class Exercise {
    public static void main(String[] args) throws Exception {
        File file=new File("daletou");
        file.createNewFile();
        test(file);
    }
    public static void test(File file) throws Exception {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入要随机几个数字");
        int n=scanner.nextInt();
        HashSet set=new HashSet();
        for (int i=0;i<n;i++){
            int random= (int) (Math.random()*36+1);
            set.add(random);

        }
        System.out.println(set);
        OutputStream os=new FileOutputStream(file);
        String arr=" ";
       for (Object obj:set){
           arr=arr+" "+obj;
       }
        System.out.println(arr);
        System.out.println("请在输入想要随机几个数字");
        int a=scanner.nextInt();
        HashSet set1=new HashSet();
        for (int i=0;i<a;i++){
            int random1= (int) (Math.random()*12+1);
            set1.add(random1);
        }
        System.out.println(set1);
        String arr1="";
        for (Object obj1:set1){
            arr1=arr1+" "+obj1;
        }
        System.out.println(arr1);
        String arr2=arr+"|"+arr1;
        byte[] byteArr=arr2.getBytes();
        os.write(byteArr);
        os.close();
    }
}
